<template>
  <!--明细页面弹出框-->
  <el-dialog
    title="银行票据打印申请明细"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="true"
    @close="closeFn"
  >
    <el-form ref="detailsForm" :model="formData" :rules="rules" label-width="130px">
      <el-card class="form-card txnInfo-card">
        <div slot="header" class="label-header-msg">
          <span>票据签发信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="交易流水号：" prop="id">
              <el-input v-model="formData.id" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出票行行号：" prop="issuedBrno">
              <el-input v-model="formData.issuedBrno" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出票行行名：" prop="issuedBrname">
              <el-input v-model="formData.issuedBrname" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出票日期：" prop="issuedDate">
              <el-date-picker
                v-model="formData.issuedDate"
                type="date"
                disabled
                value-format="yyyyMMdd"
                placeholder=""
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="票据类型：" prop="draftType">
              <el-select style="width: 100%" v-model="formData.draftType" disabled placeholder="">
                <el-option
                  v-for="dict in dictMap.DRAFT_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="票据种类：" prop="draftCode">
              <el-select style="width: 100%" v-model="formData.draftCode" disabled placeholder="">
                <el-option
                  v-for="dict in dictMap.DRAFT_CODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出票人账号：" prop="issuedActno">
              <el-input v-model="formData.issuedActno" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出票人名称：" prop="issuedName">
              <el-input v-model="formData.issuedName" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="收款人名称：" prop="payeeName">
              <el-input v-model="formData.payeeName" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出票金额：" prop="issuedAmount">
              <el-input v-model="formData.issuedAmount" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="提示付款日期：" prop="promptDate">
              <el-date-picker
                v-model="formData.promptDate"
                type="date"
                value-format="yyyyMMdd"
                placeholder=""
                disabled
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="备注：" prop="remarks">
              <el-input type="textarea" v-model="formData.remarks" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="代理付款行行号：" prop="agentBrno">
              <el-input v-model="formData.agentBrno" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="代理付款行行名：" prop="agentBrname">
              <el-input v-model="formData.agentBrname" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="录入操作员：" prop="mdTlrno">
              <el-input v-model="formData.mdTlrno" placeholder="" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="录入时间：" prop="mdTime">
              <el-date-picker
                v-model="formData.mdTime"
                type="datetime"
                value-format="yyyyMMddHHmmss"
                placeholder=""
                disabled
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="审核操作员：" prop="audTlrno">
              <el-input v-model="formData.audTlrno" placeholder="" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核时间：" prop="audTime">
              <el-date-picker
                v-model="formData.audTime"
                type="datetime"
                value-format="yyyyMMddHHmmss"
                placeholder=""
                disabled
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>
    <el-form ref="submitForm" :model="submitParams" :rules="rules" label-width="120px">
      <el-card class="form-card txnInfo-card">
        <div slot="header" class="label-header-msg">
          <span>打印信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="票据号码：" prop="draftNo">
              <el-input v-model="submitParams.draftNo" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生成方式：" prop="genType">
              <el-select style="width: 100%" v-model="submitParams.genType" placeholder="">
                <el-option
                  v-for="dict in dictMap.GEN_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" v-if="this.submitParams.genType == '2'">
          <el-col :span="12">
            <el-form-item label="密押：" prop="key">
              <el-input v-model="submitParams.key" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="打印理由：" prop="reasons">
              <el-input type="textarea" v-model="submitParams.reasons" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>

    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm" :loading="isLoading">提交</el-button>
      <el-button type="warning" @click="reset" :loading="isLoading">重置</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { approve } from "@/api/cnaps/bepsDraft/bank_note_print_apply.js";

export default {
  name: "BankNotePrintApplyDetails",
  components: {},
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      // 是否显示弹出层
      open: false,
      isLoading: false,
      // 录入参数
      submitParams: {
        draftNo: "",
        genType: "",
        key: "",
        reasons: "",
      },
      rules: {
        draftNo: [{ required: true, message: "请输入票据号码", trigger: "blur" }],
        genType: [{ required: true, message: "请选择生成方式", trigger: "change" }],
        key: [{ required: true, message: "不能为空", trigger: "blur" }],
      },
    };
  },
  mounted() {},
  methods: {
    //审核
    submitForm() {
      this.$refs["submitForm"].validate((valid) => {
        if (valid) {
          this.isLoading = true;
          approve({ ...this.formData, ...this.submitParams })
            .then((res) => {
              this.isLoading = false;
              this.$emit("editComplete", true);
              this.msgSuccess("成功!");
              this.closeFn();
            })
            .catch((err) => {
              this.isLoading = false;
              //   this.$alert(`${res.result}`, "系统提示", {
              //     confirmButtonText: "确认",
              //     type: "error",
              //     callback: (action) => {},
            });
        }
      });
    },
    // 表单重置
    reset() {
      this.resetForm("submitForm");
    },
    closeFn() {
      this.open = false;
      this.reset();
    },
    show() {
      this.open = true;
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
